﻿using System.Collections.Generic;
using Mono.Cecil;
using OpenReflect.Domain.Contracts;
using OpenReflect.Domain.Model;

namespace OpenReflect.Services.Builders
{
	public interface IAssemblyReferenceBuilder
	{
		IList<IAssemblyReference> CreateAssemblyReferences(ModuleDefinition module);
	}

	public class AssemblyReferenceBuilder : IAssemblyReferenceBuilder
	{
		#region IAssemblyReferenceBuilder Members

		public IList<IAssemblyReference> CreateAssemblyReferences(ModuleDefinition module)
		{
			var retVal = new List<IAssemblyReference>();

			foreach (AssemblyNameReference r in module.AssemblyReferences)
			{
				IAssemblyReference reference = new AssemblyReference();
				reference.Name = r.Name;
				retVal.Add(reference);
			}
			return retVal;
		}

		#endregion
	}
}